/*
 * 作者:熊猫
 * 日期:2017 - 3 - 20 11 - 0 - 25
 *
 */

package net.lainiao.morethread.Chapter8.demo4;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2017/3/20.
 */
public class Mian {
    public static void main(String[] args) throws InterruptedException {
        ForkJoinPool pool=new ForkJoinPool();
        int array[]=new int[10000];
        Task task1=new Task(array,0,array.length);
        pool.execute(task1);
        while(!task1.isDone()){
            showLog(pool);
            TimeUnit.SECONDS.sleep(1);
        }
        pool.shutdown();
        pool.awaitTermination(1,TimeUnit.DAYS);
        showLog(pool);
        System.out.println("Main Over");
    }

    private static void showLog(ForkJoinPool pool) {
        System.out.println("***********************************************");
        System.out.println("Main: Fork/Join Pool Log");
        System.out.println("Main: Fork/Join Pool :Parallelism:"+pool.getParallelism());
        System.out.println("Main: Fork/Join Pool :Pool Size:"+pool.getPoolSize());
        System.out.println("Main: Fork/Join Pool :Active Thread Count:"+pool.getActiveThreadCount());
        System.out.println("Main: Fork/Join Pool :Running Thread count:"+pool.getRunningThreadCount());
        System.out.println("Main: Fork/Join Pool :Queued Submission:"+pool.getQueuedSubmissionCount());
        System.out.println("Main: Fork/Join Pool :Queued Task:"+pool.getQueuedTaskCount());
        System.out.println("Main: Fork/Join Pool :Queued Submissions:"+pool.hasQueuedSubmissions());
        System.out.println("Main: Fork/Join Pool :Steal Count:"+pool.getStealCount());
        System.out.println("Main: Fork/Join Pool :Terminated:"+pool.isTerminated());
        System.out.println("***********************************************");
    }
}
